package com.mvd.app.ac2020;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.mvd.app.R;
import com.mvd.app.model.VideoUploadModel;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: PDA_38900_guizhou
 * @Package: com.mvd.app.adapter
 * @ClassName: MyVideoAdapter
 * @Description: java类作用描述
 * @Author: liuxj
 * @CreateDate: 2020-11-04 8:56
 * @UpdateUser: 更新者
 * @UpdateDate: 2020-11-04 8:56
 * @UpdateRemark: 更新说明
 * @Version: 1.0 BaseQuickAdapter<VideoUploadModel>
 */
public class MyVideoAdapter extends BaseAdapter {

    Context context;
    LayoutInflater inflater;
    private List<VideoUploadModel> data;
    String MODE;

    public MyVideoAdapter(Context context, List<VideoUploadModel> data, String MODE) {
        super();
        this.context = context;
        this.data = data;
        this.MODE = MODE;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        int l = 0;
        if (data != null && data.size() > 0) {
            l = data.size();
        } else {
            l = 0;
        }
        return l;
    }


    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return data.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView != null) {
            holder = (ViewHolder) convertView.getTag();
        } else {
            convertView = inflater.inflate(R.layout.item_my_video, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder.itemMyName.setText(data.get(position).getCarNO());
        holder.itemMyPriority.setText(data.get(position).getVIN());
        holder.itemMyDownloadSize.setText("正在上传中...");
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.item_my_icon)
        ImageView itemMyIcon;
        @BindView(R.id.item_my_name)
        TextView itemMyName;
        @BindView(R.id.item_my_priority)
        TextView itemMyPriority;
        @BindView(R.id.item_my_downloadSize)
        TextView itemMyDownloadSize;
        @BindView(R.id.item_my_netSpeed)
        TextView itemMyNetSpeed;
        @BindView(R.id.item_my_tvProgress)
        TextView itemMyTvProgress;

        @BindView(R.id.item_my_upload)
        Button itemMyUpload;
        @BindView(R.id.item_my_remove)
        Button itemMyRemove;
        @BindView(R.id.item_my_restart)
        Button itemMyRestart;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
